<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>有新内容吗</title>
</head>
<body>
<h1>Welcomte to Example 2a</h1>
<div id="whatsNew"></div>
<script>
    function setCookie(name, value, expries, path) {
        value = decodeURI(value);
        if (!expries) {
            var now = new Date();
            now.setMonth(now.getMonth() + 6);
            expries = now.toUTCString();
        }
        if (path) {
            path = ';path=' + path;
        }
        document.cookie = name + '=' + value + ';expries=' + expries + path;
    }

    function getCookie(name) {
        var value = document.cookie;
        var cookieStartsAt = value.indexOf(' ' + name + '=');
        if (cookieStartsAt == -1) {
            cookieStartsAt = value.indexOf(name + '=');
        }
        if (cookieStartsAt == -1) {
            value = null;
        } else {
            cookieStartsAt = value.indexOf('=', cookieStartsAt) + 1;
            var cookieEndsAt = value.indexOf(';', cookieStartsAt);
            if (cookieEndsAt == -1) {
                cookieEndsAt = value.length;
            }
            value = (value.substring(cookieStartsAt, cookieEndsAt));
        }
        return value;
    }
</script>
<script>
    var lastUpdated = new Date('Tue, 28 Dec 2020');
    var lastVisit = getCookie('LastVisit');
    if (lastVisit) {
        lastVisit = new Date(lastVisit);
        if (lastVisit < lastUpdated) {
            document.getElementById('whatsNew').innerHTML = '<a href="example-2b.html">What\'s New?</a>';
        }
    }
    var now = new Date();
    setCookie('LastVisit', now.toUTCString());
</script>
</body>
</html>